package com.itqf.controller;

import com.github.pagehelper.PageInfo;
import com.itqf.entity.GongYing;
import com.itqf.service.GongYingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.annotation.RequestScope;

import javax.servlet.ServletResponse;
import java.io.PrintWriter;

/**
 * @author: Panjianwei
 * @date: 2019/12/18 22:02
 * 代码是一门艺术，需要我们细细用心品味！
 */
@Controller
@ResponseBody
public class GongYingController {
    @Autowired
    private GongYingService gongYingService;
    @RequestMapping("/gongying/findall")
    public PageInfo<GongYing> findall(String gName, String gLinkman,@RequestParam(defaultValue = "1") int pageindex)
    {
        PageInfo<GongYing> pageinfo = gongYingService.findall(gName, gLinkman, pageindex, 1);
        return pageinfo;
    }
//    添加
    @RequestMapping("/gongying/addgongying")
    public int addgongying(GongYing gongYing, ServletResponse response)
    {
        response.setContentType("text/html;charset=utf-8");
        int addgongying = gongYingService.addgongying(gongYing);
        return addgongying;
    }
//修改
//    (1)主键查询
    @RequestMapping("/gongying/findbygId")
    public GongYing findbygId(int gId)
    {
        GongYing gongYing = gongYingService.findbygId(gId);
        return gongYing;
    }

//    (2)修改
    @RequestMapping("/gongying/update")
    public int update(GongYing gongYing)
    {
        int update = gongYingService.update(gongYing);
        return update;
    }
//    删除
    @RequestMapping("/gongying/delete")
    public int delete(int gId)
    {
        int delete = gongYingService.delete(gId);
        return delete;
    }
}
